Skip to content

London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Todo List App#1006

Open
Eugenie-A wants to merge 6 commits intoCodeYourFuture:mainfrom
Eugenie-A:Sprint-3/todo-list
Open

London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Todo List App#1006
Eugenie-A wants to merge 6 commits intoCodeYourFuture:mainfrom
Eugenie-A:Sprint-3/todo-list

Conversation

@Eugenie-A
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Added the "Delete completed tasks" button in index.html
  • Implemented deleteCompleted() in todos.mjs
  • Wrote Jest tests for deleteCompleted() in todos.test.mjs
  • Added event listener for delete completed button in script.mjs
  • Implemented deleteCompletedTodos callback in script.mjs

Questions

Why is render without parentheses a bug?

@Eugenie-A Eugenie-A added 🏕 Priority Mandatory This work is expected 🐂 Size Medium 1-4 hours 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Submit:PR Module-Data-Groups The name of the module. Core This is a core task and should be completed by all trainees labels Mar 13, 2026
@kyle-tightest kyle-tightest added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 22, 2026
@@ -1,40 +1,50 @@
<!DOCTYPE html>
<!doctype html>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not case sensitive so it doesn't matter but it is more standard to capitalise this.
did your formatter do this automatically?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was my Prettier formatter in VS Code doing it automatically on save. I know it's more standard to keep it uppercase but Prettier lowercases it by default. Prettier formatter is the standard formatter we were asked to use in our work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay no problem

Comment on lines +32 to +35
export function deleteCompleted(todos) {
const completed = todos.filter((todo) => todo.completed);
completed.forEach((todo) => todos.splice(todos.indexOf(todo), 1));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this code works, it is inefficient as you are iterating over the entire array when you do filter and then iterating over each of the filtered array items when you do forEach.
The .filter method returns an array filtered by the condition you give it.
Try and see if you can use the .filter method differently to achieve the same outcome, without needing forEach?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. I've updated the function to use filter once to get the incomplete todos, then splice to update the original array in place.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this works as well.
But again, when you do splice in that second step you're iterating over each of the filtered array items.
This is not necessary.
Try to look at the function again and see if you can do it in 1 line, instead of 2?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've combined both lines into one, the filter now happens directly inside the splice call so it's done in a single step.

@kyle-tightest kyle-tightest added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Mar 22, 2026
@Eugenie-A Eugenie-A added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 22, 2026
@kyle-tightest kyle-tightest added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 23, 2026
@Eugenie-A Eugenie-A added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core This is a core task and should be completed by all trainees Module-Data-Groups The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 🏕 Priority Mandatory This work is expected 🐂 Size Medium 1-4 hours 📅 Sprint 3 Assigned during Sprint 3 of this module Submit:PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants